#!/bin/bash

#! amount args
# ${_is_amount_arg} ${NARGS} min_equ max_equ
# if [ $? -ne 0 ]; then
#     plt_pause "from ${FNN}() :: ${_is_amount_arg} ${NARGS} min_equ:: be return 1"
#     return 1
# fi
#! normalize ptr_path -> absolut path
# ptr_path=$1
# ptr_path=$(${_abs_path} $PPWD "ptr_path") #ptr args
#! variables for cr_f_dir_insert_
# fn_name=$(${_prs_f} -n ${arg_path})
# root_path=$(${_prs_f} -d ${arg_path})
#! search in array
# [[ " ${arr[*]} " =~ " $1 " ]] && echo "true" || echo "false"
#! ${array[@]:1} all from 1 member arr

# echo -e "${GREEN}\${g_args[@]} = ${g_args[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${e_args[@]} = ${e_args[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${f_args[@]} = ${f_args[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${ARGS[@]} = ${ARGS[*]}${NORMAL}"     #print variable
# echo -e "${GREEN}\${NARGS} = ${NARGS}${NORMAL}"         #print variable
# echo -e "${GREEN}\${ARGS0} = ${ARGS0}${NORMAL}"         #print variable
# echo -e "${GREEN}\${ARGS1} = ${ARGS1}${NORMAL}"         #print variable
# echo -e "${GREEN}\${ARGS2} = ${ARGS2}${NORMAL}"         #print variable

# echo -e "${GREEN}\${dir_fns_} = ${dir_fns_}${NORMAL}" #print variable

# echo -e "${GREEN}\${local_var_wrap_arr[@]} = ${local_var_wrap_arr[*]}${NORMAL}" #print variable
# echo -e "${GREEN}\${local_var_fn_arr[@]} = ${local_var_fn_arr[*]}${NORMAL}"     #print variable

# echo -e "${GREEN}\$ratis = $ratis${NORMAL}" #print variable

# echo "that ${FNN}.sal"

#! every from list_strong_cntls by able
# list_strong_cntls=(?str_ ?del_ ?parr_)
# for item in "${list_strong_cntls[@]}"; do
#     echo -e "${GREEN}\$item = $item${NORMAL}" #print variable
#     echo "$(eval echo \$"$item")"
#     if [ -z "$(eval echo \$"$item")" ]; then
#         plt_info "from ${FNN}() :: $item is empty :: be return 1"
#         return 1
#     fi
# done

#! once dpl_ or bcp_ mast be able (0 1)
# sum_1=$((${dpl_:-0} + ${bcp_:-0}))
# echo -e "${GREEN}\$sum_1 = $sum_1${NORMAL}"

# if [ "${sum_1:-0}" -ne 1 ]; then
#     plt_info "from ${FNN}() once dpl_ or bcp_ mast be able :: be return 1"
#     return 1
# fi

#?--------------------------------------------------------
#?---------------------------------------------
#?---------------------------------------
if [ -z "${ARGS0}" ]; then
    for item0 in $("${_f2e}" ${PLT_PATH}/.d/.opus/fn_sal.opus); do
        # echo -e "${GREEN}\$item0 = $item0 ${NORMAL}" #print variable
        for item1 in $("${_dd2e}" ${item0}); do
            # echo -e "${GREEN}\$item1 = $item1 ${NORMAL}" #print variable
            h_dir="${item0}/${item1}/${item1}.d.h"
            e_dir="${item0}/${item1}"
            if [ -f ${h_dir}/name.insert ]; then
                name_str="$(cat "${h_dir}"/name.insert)"
            fi
            if [ -f ${h_dir}/main.insert ]; then
                main_str="$(cat "${h_dir}"/main.insert)"
            fi
            if [ -f ${h_dir}/tags.insert ]; then
                tags_str="$(f2str_ "${h_dir}"/tags.insert)"
            fi

            echo -e "
${BLUE}file://${e_dir}${NORMAL}
${GREEN}${name_str:6}${NORMAL} 
${RED}${main_str:6}${NORMAL}
${CYAN}${tags_str}${NORMAL}"
        done
    done
    return 0
fi

if [ "${ARGS0}" == "tag" ]; then

    all_tag_file=${PLT_PATH}/.d/.sal.ax/uE_/uE_.d.repo/all_tags.list
    : >"${all_tag_file}"

    for item0 in $(f2e ${PLT_PATH}/.d/.opus/fn_sal.opus); do

        for item1 in $(dd2e ${item0}); do

            h_dir="${item0}/${item1}/${item1}.d.h"
            e_dir="${item0}/${item1}"

            if [ -f ${h_dir}/tags.insert ]; then
                for item2 in $(cat "${h_dir}"/tags.insert); do

                    if ! [ "${item2}" == "TAGS:" ]; then
                        if ! grep -w "${item2}" "${all_tag_file}" >/dev/null; then
                            # echo 0 "${item2}"
                            echo "${item2}" >>"${all_tag_file}"
                        fi
                    fi
                done
            fi

        done

    done
    cat "${all_tag_file}"
    return 0

fi

#?---------------------------------------
#?---------------------------------------------
#?--------------------------------------------------------
